//
//  DetailCommentCell.swift
//  maosheng
//
//  Created by lxl on 2019/8/20.
//

import UIKit

class DetailCommentCell: UITableViewCell {
    let userImg = UIImageView()
    let userLab = UILabel()
    let commentLab = UILabel()

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        configCell()
//        contentView.backgroundColor = KYP_f2f2f2_COLOR
        
    }
    
    
    func configCell() -> Void {
        let imgHeight = 24
        userImg.layer.cornerRadius = CGFloat(imgHeight/2)
        userImg.layer.masksToBounds = true
        contentView.addSubview(userImg)
        userImg.snp.makeConstraints { (make) in
            make.top.left.equalTo(15)
            make.width.height.equalTo(imgHeight)
        }
        
        contentView.addSubview(userLab)
        userLab.textColor = KYP_999999_COLOR
        userLab.font = UIFont(name: PF_Regular, size: 12)
        userLab.snp.makeConstraints { (make) in
            make.left.equalTo(userImg.snp.right).offset(11)
            make.top.equalTo(userImg).offset(6)
        }
        
        commentLab.numberOfLines = 0
        contentView.addSubview(commentLab)
        commentLab.textColor = KYP_333333_COLOR
        commentLab.font = UIFont(name: PF_Regular, size: 11)
        commentLab.snp.makeConstraints { (make) in
            make.left.equalTo(userLab)
            make.right.equalTo(-15)
            make.top.equalTo(userLab.snp.bottom).offset(9)
            make.bottom.equalTo(-5)
        }
    }

    
    func setTHeCommentInfo(model : HomeCommentModel) -> Void {
        userLab.text = model.creatorUserDisplayName
        commentLab.text = model.body
        if let imgUrl = model.creatorUserAvatar{
            userImg.kf.setImage(with: URL(string: imgUrl))
        }
    }
}
